home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / obero / oberon_lib.lha / oberon-a / source1.lha / source / Amiga / Workbench.mod < prev   
Text File  |  1994-08-08  |  10KB  |  343 lines

  1. (**************************************************************************
  2.  
  3.      $RCSfile: Workbench.mod $
  4.   Description: Interface to workbench.library
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 3.2 $
  8.       $Author: fjc $
  9.         $Date: 1994/08/08 01:11:46 $
  10.  
  11.   Includes Release 40.15
  12.  
  13.   (C) Copyright 1985-1993 Commodore-Amiga, Inc.
  14.       All Rights Reserved
  15.  
  16.   Oberon-A interface Copyright © 1994, Frank Copeland.
  17.   This file is part of the Oberon-A Interface.
  18.   See Oberon-A.doc for conditions of use and distribution.
  19.  
  20. ***************************************************************************)
  21.  
  22. MODULE Workbench;
  23.  
  24. (*
  25. ** $C- CaseChk       $I- IndexChk  $L+ LongAdr   $N- NilChk
  26. ** $P- PortableCode  $R- RangeChk  $S- StackChk  $T- TypeChk
  27. ** $V- OvflChk       $Z- ZeroVars
  28. *)
  29.  
  30. IMPORT
  31.   SYS := SYSTEM, E := Exec, U := Utility, D := Dos, I := Intuition;
  32.  
  33.  
  34. (* Pointers are declared first for convenience *)
  35.  
  36. TYPE
  37.  
  38.   OldDrawerDataPtr * = CPOINTER TO OldDrawerData;
  39.   DrawerDataPtr *    = CPOINTER TO DrawerData;
  40.   DiskObjectPtr *    = CPOINTER TO DiskObject;
  41.   FreeListPtr *      = CPOINTER TO FreeList;
  42.   AppMessagePtr *    = CPOINTER TO AppMessage;
  43.   WBStartupPtr *     = CPOINTER TO WBStartup;
  44.   WBArgPtr *         = CPOINTER TO WBArg;
  45.   AppWindowPtr *     = CPOINTER TO AppWindow;
  46.   AppIconPtr *       = CPOINTER TO AppIcon;
  47.   AppMenuItemPtr *   = CPOINTER TO AppMenuItem;
  48.  
  49.  
  50. (*
  51. **      $VER: startup.h 36.3 (11.7.90)
  52. **
  53. **      workbench startup definitions
  54. *)
  55.  
  56.  
  57. TYPE
  58.  
  59.   WBArg * = RECORD
  60.     lock * : D.FileLockPtr;      (* a lock descriptor *)
  61.     name * : E.STRPTR;           (* a string relative to that lock *)
  62.   END; (* WBArg *)
  63.  
  64.   WBArguments * = ARRAY 32767 OF WBArg;
  65.   WBArgumentsPtr * = CPOINTER TO WBArguments;
  66.  
  67.   WBStartup * = RECORD (E.Message) (* a standard message structure *)
  68.     process *    : D.ProcessId;    (* the process descriptor for you *)
  69.     segment *    : D.BPTR;         (* a descriptor for your code *)
  70.     numArgs *    : LONGINT;        (* the number of elements in ArgList *)
  71.     toolWindow * : E.STRPTR;       (* description of window *)
  72.     argList *    : WBArgumentsPtr; (* the arguments themselves *)
  73.   END; (* WBStartup *)
  74.  
  75.  
  76. (*
  77. **      $VER: workbench.h 40.1 (26.8.93)
  78. **
  79. **      workbench.library general definitions
  80. *)
  81.  
  82. CONST
  83.  
  84.   disk *    = 1;
  85.   drawer *  = 2;
  86.   tool *    = 3;
  87.   project * = 4;
  88.   garbage * = 5;
  89.   device *  = 6;
  90.   kick *    = 7;
  91.   appIcon * = 8;
  92.  
  93. TYPE
  94.  
  95.   OldDrawerData * = (* pre V36 definition *)
  96.   RECORD (I.NewWindow)         (* args to open window *)
  97.     currentX *  : LONGINT;     (* current x coordinate of origin *)
  98.     currentY *  : LONGINT;     (* current y coordinate of origin *)
  99.   END; (* OldDrawerData *)
  100.  
  101. CONST
  102.  
  103. (* the amount of DrawerData actually written to disk *)
  104.   oldDrawerDataFileSize * = SIZE (OldDrawerData);
  105.  
  106. TYPE
  107.  
  108.   DrawerData * = RECORD (I.NewWindow) (* args to open window *)
  109.     currentX *  : LONGINT;     (* current x coordinate of origin *)
  110.     currentY *  : LONGINT;     (* current y coordinate of origin *)
  111.     ddFlags *   : SET;         (* flags for drawer *)
  112.     viewModes * : E.WSET;      (* view mode for drawer *)
  113.   END; (* DrawerData *)
  114.  
  115. CONST
  116.  
  117. (* the amount of DrawerData actually written to disk *)
  118.   drawerDataFileSize * = SIZE (DrawerData);
  119.  
  120. TYPE
  121.  
  122.   ToolTypePtr * = CPOINTER TO ARRAY 32767 OF E.STRPTR;
  123.  
  124.   DiskObject * = RECORD
  125.     magic *       : E.UWORD;  (* a magic number at the start of the file *)
  126.     version *     : E.UWORD;  (* a version number, so we can change it *)
  127.     gadget *      : I.Gadget; (* a copy of in core gadget *)
  128.     type *        : E.UBYTE;
  129.     defaultTool * : E.STRPTR;
  130.     toolTypes *   : ToolTypePtr;
  131.     currentX *    : LONGINT;
  132.     currentY *    : LONGINT;
  133.     drawerData *  : DrawerDataPtr;
  134.     toolWindow *  : E.STRPTR; (* only applies to tools *)
  135.     stackSize *   : LONGINT;  (* only applies to tools *)
  136.   END; (* DiskObject *)
  137.  
  138. CONST
  139.  
  140.   diskMagic *    = 0E310H;  (* a magic number, not easily impersonated *)
  141.   diskVersion *  = 1;       (* our current version number *)
  142.   diskRevision * = 1;       (* our current revision number *)
  143. (* I only use the lower 8 bits of Gadget.UserData for the revision # *)
  144.   diskRevisionMask * = 255;
  145.  
  146. TYPE
  147.  
  148.   FreeList * = RECORD
  149.     numFree * : INTEGER;
  150.     memList * : E.List;
  151.   END; (* FreeList *)
  152.  
  153. CONST
  154.  
  155. (* workbench does different complement modes for its gadgets.
  156. ** It supports separate images, complement mode, and backfill mode.
  157. ** The first two are identical to intuitions GADGIMAGE and GADGHCOMP.
  158. ** backfill is similar to GADGHCOMP, but the region outside of the
  159. ** image (which normally would be color three when complemented)
  160. ** is flood-filled to color zero.
  161. *)
  162.   gflgGadgBackFill * = {0};
  163.   gadgBackFill * = {0};
  164.  
  165. (* if an icon does not really live anywhere, set its current position
  166. ** to here
  167. *)
  168.   noIconPosition * = 80000000H;
  169.  
  170. (* workbench now is a library.  this is it's name *)
  171.   name * = "workbench.library";
  172.  
  173. (* If you find amVersion >= amVERSION, you know this structure has
  174.  * at least the fields defined in this version of the include file
  175.  *)
  176.   amVersion * = 1;
  177.  
  178. TYPE
  179.  
  180.   AppMessage * = RECORD (E.Message)  (* standard message structure *)
  181.     amType *   : E.UWORD;            (* message type *)
  182.     userData * : SYS.LONGWORD;       (* application specific *)
  183.     id *       : E.ULONG;            (* application definable ID *)
  184.     numArgs *  : LONGINT;            (* # of elements in arglist *)
  185.     argList *  : WBArgumentsPtr;     (* the arguements themselves *)
  186.     version *  : E.UWORD;            (* will be amVERSION *)
  187.     class *    : E.WSET;             (* message class *)
  188.     mouseX *   : INTEGER;            (* mouse x position of event *)
  189.     mouseY *   : INTEGER;            (* mouse y position of event *)
  190.     seconds *  : E.ULONG;            (* current system clock time *)
  191.     micros *   : E.ULONG;            (* current system clock time *)
  192.     reserved * : ARRAY 8 OF E.ULONG; (* avoid recompilation *)
  193.   END; (* AppMessage *)
  194.  
  195. CONST
  196.  
  197. (* types of app messages *)
  198.   amTypeAppWindow *   = 7;  (* app window message    *)
  199.   amTypeAppIcon *     = 8;  (* app icon message      *)
  200.   amTypeAppMenuItem * = 9;  (* app menu item message *)
  201.  
  202. TYPE
  203.  
  204. (*
  205.  * The following structures are private.  These are just stub
  206.  * structures for code compatibility...
  207.  *)
  208.   AppWindow *   = RECORD END;
  209.   AppIcon *     = RECORD END;
  210.   AppMenuItem * = RECORD END;
  211.  
  212. (*-- Library Base variable --------------------------------------------*)
  213.  
  214. TYPE
  215.  
  216.   WorkbenchBasePtr * = CPOINTER TO WorkbenchBase;
  217.   WorkbenchBase = RECORD (E.Library) END;
  218.  
  219. VAR
  220.  
  221.   base *  : WorkbenchBasePtr;
  222.  
  223.  
  224. (*-- Library Functions ------------------------------------------------*)
  225.  
  226. (*
  227. **      $VER: wb_protos.h 38.4 (31.5.92)
  228. *)
  229.  
  230. (* --- functions in V36 or higher (distributed as Release 2.0) ---*)
  231.  
  232. LIBCALL (base : WorkbenchBasePtr) AddAppWindowA*
  233.   ( id       [0] : E.ULONG;
  234.     userdata [1] : SYS.LONGWORD;
  235.     window   [8] : I.WindowPtr;
  236.     msgport  [9] : E.MsgPortPtr;
  237.     taglist [10] : ARRAY OF U.TagItem )
  238.   : AppWindowPtr;
  239.   -48;
  240. LIBCALL (base : WorkbenchBasePtr) AddAppWindow*
  241.   ( id       [0]   : E.ULONG;
  242.     userdata [1]   : SYS.LONGWORD;
  243.     window   [8]   : I.WindowPtr;
  244.     msgport  [9]   : E.MsgPortPtr;
  245.     taglist [10].. : U.Tag )
  246.   : AppWindowPtr;
  247.   -48;
  248. LIBCALL (base : WorkbenchBasePtr) RemoveAppWindow*
  249.   ( appWindow [8] : AppWindowPtr )
  250.   : BOOLEAN;
  251.   -54;
  252. (*
  253.  * This function is not yet implemented.  It passes a parameter in A4,
  254.  * which will require a change in the compiler.  Use the procedure
  255.  * defined later in the module until this is fixed.
  256.  *)
  257. LIBCALL (base : WorkbenchBasePtr) AddAppIconA*
  258.   ( id       [0] : E.ULONG;
  259.     userdata [1] : SYS.LONGWORD;
  260.     text     [8] : ARRAY OF CHAR;
  261.     msgport  [9] : E.MsgPortPtr;
  262.     lock    [10] : D.FileLockPtr;
  263.     diskobj [11] : DiskObjectPtr;
  264.     taglist [12] : ARRAY OF U.TagItem )
  265.   : AppIconPtr;
  266.   -60;
  267. LIBCALL (base : WorkbenchBasePtr) AddAppIcon*
  268.   ( id       [0]  : E.ULONG;
  269.     userdata [1]  : SYS.LONGWORD;
  270.     text     [8]  : ARRAY OF CHAR;
  271.     msgport  [9]  : E.MsgPortPtr;
  272.     lock    [10]  : D.FileLockPtr;
  273.     diskobj [11]  : DiskObjectPtr;
  274.     taglist [12]..: U.Tag )
  275.   : AppIconPtr;
  276.   -60;
  277. (**)
  278.  
  279. LIBCALL (base : WorkbenchBasePtr) RemoveAppIcon*
  280.   ( appIcon [8] : AppIconPtr )
  281.   : BOOLEAN;
  282.   -66;
  283. LIBCALL (base : WorkbenchBasePtr) AddAppMenuItemA*
  284.   ( id       [0] : E.ULONG;
  285.     userdata [1] : SYS.LONGWORD;
  286.     text     [8] : ARRAY OF CHAR;
  287.     msgport  [9] : E.MsgPortPtr;
  288.     taglist [10] : ARRAY OF U.TagItem )
  289.   : AppMenuItemPtr;
  290.   -72;
  291. LIBCALL (base : WorkbenchBasePtr) AddAppMenuItem*
  292.   ( id       [0]   : E.ULONG;
  293.     userdata [1]   : SYS.LONGWORD;
  294.     text     [8]   : ARRAY OF CHAR;
  295.     msgport  [9]   : E.MsgPortPtr;
  296.     taglist [10].. : U.Tag )
  297.   : AppMenuItemPtr;
  298.   -72;
  299. LIBCALL (base : WorkbenchBasePtr) RemoveAppMenuItem*
  300.   ( appMenuItem [8] : AppMenuItemPtr )
  301.   : BOOLEAN;
  302.   -78;
  303.  
  304. (*--- functions in V39 or higher (Release 3) ---*)
  305.  
  306. LIBCALL (base : WorkbenchBasePtr) WBInfo *
  307.   ( lock    [8] : D.FileLockPtr;
  308.     name    [9] : ARRAY OF CHAR;
  309.     screen [10] : I.ScreenPtr );
  310.   -90;
  311.  
  312.  
  313. (*-- Library Base variable --------------------------------------------*)
  314. (* $L- Address globals through A4 *)
  315.  
  316.  
  317. (*-----------------------------------*)
  318. PROCEDURE* CloseLib ();
  319.  
  320. BEGIN (* CloseLib *)
  321.   IF base # NIL THEN E.base.CloseLibrary (base) END;
  322. END CloseLib;
  323.  
  324. (*-----------------------------------*)
  325. PROCEDURE OpenLib * (mustOpen : BOOLEAN);
  326.  
  327. BEGIN (* OpenLib *)
  328.   IF base = NIL THEN
  329.     base :=
  330.       SYS.VAL
  331.         ( WorkbenchBasePtr,
  332.           E.base.OpenLibrary (name, E.libraryMinimum) );
  333.     IF base # NIL THEN SYS.SETCLEANUP (CloseLib)
  334.     ELSIF mustOpen THEN HALT (100)
  335.     END;
  336.   END;
  337. END OpenLib;
  338.  
  339.  
  340. BEGIN
  341.   base := NIL
  342. END Workbench.
  343.